//下拉树（授权）
function treeThreeInit(){
	$('#treeThree .tree-one div.tree-children div p.tree-arrow').click(function() {
		$(this).parent().parents('div.tree-children').nextAll('ul').slideToggle(300);
		if ($(this).find('img').attr('src') ==  basePath+'/static/user/img/icon_select_up.png') {
			$(this).find('img').attr('src', basePath+'/static/user/img/icon_select_down.png');
			$(this).parent().siblings().find('img').attr('src', basePath+'/static/user/img/icon_select_up.png');
		} else {
			$(this).find('img').attr('src', basePath+'/static/user/img/icon_select_up.png')
		}
	})
	$('#treeThree .tree-one ul').hide();

	layui.use(['form', 'jquery' ], function () {
		$ = layui.jquery;
		form = layui.form;
		//监听多选框点击事件
		form.on('checkbox(switchTest)', function (data) {
			if( data.elem.checked){
				var arr =  $(this).parent().parent().parent().parent().find("input");
				$.each(arr, function(i, obj) {
					$(obj).prop("checked",true);
				});
			}else{
				var arr =  $(this).parent().parent().parent().parent().find("input");
				$.each(arr, function(i, obj) {
					$(obj).prop("checked",false);;
				});
				var orgId=$(this).attr("id");
				while (1){
					var parentOrgId=$("#"+orgId).data("parentorgid");
					if(!isNull(parentOrgId)){
						$("#"+parentOrgId).prop("checked",false);
						orgId=parentOrgId;
					}else{
						break;
					}
				}
			}
			form.render('checkbox');
		});
	})
}